#pragma once

#include "variable.h"

namespace solver
{
	class literal
	{
	public:
		variable_reference ref;
		variable_value  val;
		bool star;

		literal()
		{
			;
		}

		literal(const literal& lit) : ref(lit.ref), val(lit.val), star(lit.star)
		{

		}

		literal(const literal&& lit) : ref(lit.ref), val(lit.val), star(lit.star)
		{

		}

		literal(variable_reference xref, variable_value xspin) : ref(xref), val(xspin), star(false)
		{

		}

		literal(variable_reference xref) : ref(xref), val(0), star(true)
		{

		}

		literal &operator = (const literal& lit) 
		{
			ref = lit.ref;
			val = lit.val;
			star = lit.star;
			return *this;
		}

		bool matches(const literal& b) const
		{
			return ref == b.ref && (val == b.val || star || b.star);
		}

		bool operator == (const literal& b) const
		{
			return ref == b.ref && star == b.star && val == b.val;
		}

		bool operator != (const literal &b) const
		{
			return !(*this == b);
		}

		bool operator < (const literal &b) const
		{
			return ref < b.ref || star < b.star || val < b.val;
		}

		bool operator > (const literal &b) const
		{
			return ref > b.ref || star > b.star || val > b.val;
		}

	};
}
